package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Ddfenlei;
import com.ruoyi.system.service.IDdfenleiService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 订单类型Controller
 * 
 * @author ruoyi
 * @date 2024-08-15
 */
@RestController
@RequestMapping("/system/ddfenlei")
public class DdfenleiController extends BaseController
{
    @Autowired
    private IDdfenleiService ddfenleiService;

    /**
     * 查询订单类型列表
     */
    @PreAuthorize("@ss.hasPermi('system:ddfenlei:list')")
    @GetMapping("/list")
    public TableDataInfo list(Ddfenlei ddfenlei)
    {
        startPage();
        List<Ddfenlei> list = ddfenleiService.selectDdfenleiList(ddfenlei);
        return getDataTable(list);
    }

    /**
     * 导出订单类型列表
     */
    @PreAuthorize("@ss.hasPermi('system:ddfenlei:export')")
    @Log(title = "订单类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Ddfenlei ddfenlei)
    {
        List<Ddfenlei> list = ddfenleiService.selectDdfenleiList(ddfenlei);
        ExcelUtil<Ddfenlei> util = new ExcelUtil<Ddfenlei>(Ddfenlei.class);
        util.exportExcel(response, list, "订单类型数据");
    }

    /**
     * 获取订单类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:ddfenlei:query')")
    @GetMapping(value = "/{ddflId}")
    public AjaxResult getInfo(@PathVariable("ddflId") Long ddflId)
    {
        return success(ddfenleiService.selectDdfenleiByDdflId(ddflId));
    }

    /**
     * 新增订单类型
     */
    @PreAuthorize("@ss.hasPermi('system:ddfenlei:add')")
    @Log(title = "订单类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Ddfenlei ddfenlei)
    {
        return toAjax(ddfenleiService.insertDdfenlei(ddfenlei));
    }

    /**
     * 修改订单类型
     */
    @PreAuthorize("@ss.hasPermi('system:ddfenlei:edit')")
    @Log(title = "订单类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Ddfenlei ddfenlei)
    {
        return toAjax(ddfenleiService.updateDdfenlei(ddfenlei));
    }

    /**
     * 删除订单类型
     */
    @PreAuthorize("@ss.hasPermi('system:ddfenlei:remove')")
    @Log(title = "订单类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ddflIds}")
    public AjaxResult remove(@PathVariable Long[] ddflIds)
    {
        return toAjax(ddfenleiService.deleteDdfenleiByDdflIds(ddflIds));
    }
}
